local GameManager = { }

function UseItemAllAck(msg)
	CS.UnityEngine.Debug.Log(msg.name)
	CS.UnityEngine.Debug.Log(msg.id)
end

function GameManager:init()
    CS.UnityEngine.Debug.Log('~~~ GameManager lua start ~~~')

    NetworkManager.initialize()
    UIManager.initialize()

    -- -- Example: Network message register
    -- PB_addressbook:RegisterAction(PB_addressbook.Person, UseItemAllAck)
end

function GameManager:update(deltaTime)

    -- Example: Network message encode and send
    if (CS.UnityEngine.Input.GetKeyDown(CS.UnityEngine.KeyCode.A)) then 
        local person = {
            name = "alice",
            id = 345
        }

        local data = NetworkManager.encode(PB_addressbook.PersonC2S, person)
        NetworkManager.sendMsg(PB_addressbook.PersonC2S, data)
    end 

    UIManager.update()
end

function GameManager:fixedUpdate()

end

function GameManager:onDestroy()
    UIManager.onDestroy()
    Event.clearAll()
end

return GameManager